The Wallet Configuration in Sequence Wallets defines access control, signers, and signature weight.
threshold
- The required “weight sum” needed for a signature to be considered valid.checkpoint
- Used as a salt and ordering mechanism for wallet updates.tree
- Determines the signers and their weights for the wallet.threshold
is a uint16
; it can have any value between 0 and 65535. Signatures are only considered valid or invalid if the sum of the weights of the signers that signed the transaction is greater or equal to the threshold.
checkpoint
is a uint32
. During wallet creation, a semi-random value can be provided to generate independent wallets with the same initial configuration. Then, during normal operation, the checkpoint
is used by Light State Sync to ensure that wallet updates are applied in the correct order.
tree
is an unbalanced binary Merkle tree, where each leaf may contain a signer, a static signature, or a subtree. The tree can represent any combination of signers and weights and can be used to create complex multi-signature wallets.
The possible leaf types are:
address
and a uint8
weight. The weight is how much the signer contributes to the threshold.
The address can belong to either an ERC1271
compliant contract or an EOA
wallet.
The leaf hash is calculated as follows:
Infinity
.
Notice static subdigests that exist within nested trees will have their “Infinity” weight reduced to the weight of the nested tree.
The leaf hash is calculated as follows:
weight
(uint8
)threshold
(uint16
)tree
internal threshold
within the subtree it is considered valid, and the external weight
is added to the parent tree. Any number of nested configurations can be created, and it is possible to create multiple nesting levels.
This pattern can be used, among other things, to express the following scenarios:
threshold == 0
or threshold > total weight
will result in fully unauthenticated wallets or inaccessible wallets respectively.configuration
is never stored as a whole; instead, the Merkle tree is hashed into a single bytes32
value, this is internally called the imageHash
of the configuration.
The imageHash
is calculated as follows:
hashTree
function is a recursive function that hashes the tree into a single bytes32
value, pseudo code for the hashTree
function is as follows:
imageHash
of the initial configuration as the SALT during the CREATE2
deployment of the wallet.
Wallets are deployed by calling the deploy
function of the Factory
contract, which takes the following parameters:
mainModule
: The address of the initial code implementation of the wallet.salt
: The imageHash
of the initial configuration.MainModule
should always be used as the initial code implementation of the wallet. The MainModule
validates the imageHash
(during signature validation) by re-computing the counterfactual address of the wallet, hence it does not require any storage initialization.If the imageHash
is ever changed, MainModule
will automatically replace the wallet code implementation with MainModuleUpgradeable
, while handling the storage initialization.